#include<stdio.h>
#include<stdlib.h>

int main()
{
	FILE *outfile;
	int i,j,MAX; 
	double number[33][5];
	double schoolnum,num1,num2,num3,average;
	printf("please type down the number of your students\n");
	scanf("%d",&MAX);
	printf("Now input all the information about all the students in the order like schoolnumber,Math,English,Music:\n");
	for(i=0;i<MAX;i++)/*???*/ 
	{   
		scanf("%lf %lf %lf %lf",&schoolnum,&num1,&num2,&num3);
		average=(num1+num2+num3)/3;
		number[i][0]=schoolnum;
		number[i][1]=num1;
		number[i][2]=num2;
		number[i][3]=num3;
		number[i][4]=average;
		
	}
	  
	
	outfile=fopen("stud.csv","w");
	
	
	for(j=0;j<MAX;j++)
	{
		fprintf(outfile,"%10.0lf,%3.1lf,%3.1lf,%3.1lf,%3.2lf\n",number[j][0],number[j][1],number[j][2],number[j][3],number[j][4]);
	}
	fclose(outfile);
	return 0;
 } 
